import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { fileURLToPath } from 'url'
import { dirname, resolve } from 'path'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      '@/g-utils': resolve(__dirname, 'src/g-utils'),
      '@/g-component': resolve(__dirname, 'src/g-component'),
      '@/g-types': resolve(__dirname, 'src/g-types'),
      '@/g-hooks': resolve(__dirname, 'src/g-hooks'),
      '@/g-config': resolve(__dirname, 'src/g-config'),
      '@/g-index': resolve(__dirname, 'src/g-index'),
      '@/g-page': resolve(__dirname, 'src/g-page'),
      '@/g-server': resolve(__dirname, 'src/g-server'),
      '@/g-assets': resolve(__dirname, 'src/g-assets'),
    }
  },
  server: {
    port: 3000,
    open: true,
    host: true,
  },
})
